package axdoc.rule.check.impl;

import com.alibaba.fastjson.JSONObject;

import axdoc.rule.check.AbsCheck;
import axdoc.rule.check.LoadChecksUtil;
import axdoc.util.StringUtils;

public class CheckCityRule extends AbsCheck {

	public CheckCityRule() {
		super();
	}

	public CheckCityRule(String citys) {
		this.citys = citys;
		this.cname = this.getClass().getName();
	}

	public String citys;

	public String getCitys() {
		return citys;
	}

	public void setCitys(String citys) {
		this.citys = citys;
	}

	@Override
	public boolean check(JSONObject obj) {
		String city = obj.getString("city");
		LoadChecksUtil.logger.info("[校验医生职称][titles:" + citys + "][title:" + city + "]");
		
		if (StringUtils.isEmpty(citys) || citys.equals("0")) {
			return true;
		} else {
			if (!citys.contains(city)) {
				LoadChecksUtil.logger.info("[校验医生职称][医生职称不匹配]");
				return false;
			} else if (StringUtils.isEmpty(city)) {
				LoadChecksUtil.logger.info("[校验医生职称][医生没有职称]");
				return false;
			}
		}
		return true;
	}

}
